classMethods.md.php
<?php
$instanceArg = '$'.lcfirst($class['name']);
foreach ($class['method'] as $m):
$declare = substr($m['definition'], 0, strpos($m['definition'], '('));
$declareParts = explode(' ', $declare);
if ($visibility!=='*'){
if (!in_array($visibility, $declareParts))continue;
}
$isStatic = false;
if (in_array('static',$declareParts))$isStatic = true;
$pos = strpos($m['definition'],$m['name']);
$cleanDefinition = substr($m['definition'],$pos);
$pos = strpos($cleanDefinition, '{');
$cleanDefinition = trim(substr($cleanDefinition,0,$pos));
//special definition conversions:
// static should be ClassName::method(...)
// __construct should be new ClassName(...)
// other should be $className->method(...)
if ($m['name']=='__construct'){
$cleanDefinition = $instanceArg.' = new '.$class['name'].substr($cleanDefinition,strlen('__construct'));
} else if ($isStatic){
$cleanDefinition = $class['name'].'::'.$cleanDefinition;
} else {
$cleanDefinition = $instanceArg.'->'.$cleanDefinition;
}
$description = $m['dockblock']['tip']??$m['docblock']['description']??'';
$description = str_replace("\n", "\n ", $description);
?>
- `<?=$cleanDefinition?>`: <?=$description?>
<?php
foreach ($m['docblock']??[] as $verb=>$text){
if ($verb=='src'||$verb=='description'||$verb=='type'||$verb=='tip')continue;
echo " - `@$verb`: $text\n";
}
endforeach;
// print_r($class);